package com.talkweb.historylib.slice;

import com.talkweb.historylib.ResourceTable;
import com.talkweb.historylib.fraction.ImageShowFraction;
import com.talkweb.securitycamera.common.base.BaseAbilitySlice;
import com.talkweb.securitycamera.common.base.BaseFractionAbilitySlice;
import com.talkweb.securitycamera.common.constans.Constant;
import ohos.aafwk.content.Intent;

/**
 * @version 1.0.1
 * @description:
 * @program: security-camera
 * @Author xiaozhijun
 * @Date 2021/2/4 9:05
 */
public class LargeImageSlice extends BaseFractionAbilitySlice {

    private ImageShowFraction imageShowFraction;

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_ability_image;
    }




    @Override
    protected void initView(Intent intent) {
        super.initView(intent);
        int initIndex = intent != null ? intent.getIntParam(Constant.INIT_POSITION, 0) : 0;

        imageShowFraction = new ImageShowFraction(initIndex);
        addFraction(ResourceTable.Id_large_image_stack, imageShowFraction);

    }

    @Override
    protected void onStop() {
        super.onStop();
        if (imageShowFraction != null) {
            removeFraction(imageShowFraction);
        }
    }

    @Override
    protected void onActive() {
        super.onActive();
        Intent intenta = new Intent();
        intenta.setParam(Constant.HAS_CHANGED, true);
        getAbility().setResult(Constant.DATA_CHANGED_CODE, intenta);
    }
}
